package com.gitee.jktantan.hikaricp.support.simplejndi;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.osjava.sj.loader.convert.Converter;

import java.util.Properties;

/**
 * 支持simple-jndi
 * Hikaricp是怎么配置的，这里就怎么配置，如：
 * oracle_test/converter=com.gitee.jktantan.hikaricp.support.simplejndi.HikaricpDataSourceConverter
 * oracle_test/type=javax.sql.DataSource
 * .........其他为hikaricp配置
 */
public class HikaricpDataSourceConverter implements Converter {
    @Override
    public Object convert(Properties properties, String type) {
        properties.remove("converter");
        properties.remove("type");
//        HikariConfig config = new HikariConfig(properties);
//        HikariDataSource ds = new HikariDataSource(new HikariConfig(properties));
        return new HikariDataSource(new HikariConfig(properties));
    }
}
